
<%@page import="com.liferay.portal.kernel.util.Constants"%>
<%@page import="qldc.pm.qlktcsdldc.actions.ActionHandlerConstant"%>
<%@ include file="../init.jsp"%>

<%

	String redirect = ParamUtil.getString(request, "redirect");
	
	PortletURL backURL = renderResponse.createRenderURL();
	backURL.setParameter("mvcPath", "/html/qlktcsdldc/danh_muc_so_ban_nganh.jsp");
	backURL.setParameter("tabs1", QLKTCSDLDCContants.PAGEID_DMSBN_MAN_HINH_CHINH);
	backURL.setParameter("redirect", redirect);
%>

<portlet:actionURL var="addSoBanNganhURL">
	<portlet:param name="<%=ActionHandlerConstant.ACTION_HANDLER_PARAM%>" value="<%=ActionHandlerConstant.DANH_MUC_SO_BAN_NGANH_ACTION%>" />
	<portlet:param name="<%=Constants.ACTION%>" value="addSoBanNganh" />
	<portlet:param name="redirect" value="<%=backURL.toString() %>" />
</portlet:actionURL>

<h2 class="tle-Content">
	<liferay-ui:message key="them-moi-so-ban-nghanh" />
</h2>
<div class="main-Content">
	<form name="<portlet:namespace/>fmThemMoiSoBanNganh" id="<portlet:namespace/>fmThemMoiSoBanNganh" method="POST" action="" onsubmit="return false;">
		<table class="gridnormal">
			<tr>
				<td>
					<liferay-ui:message key="ten-so-ban-nganh" />
				</td>
				
				<td>
					<input type="text" name="<portlet:namespace/>tenSoBanNganh" id="<portlet:namespace/>tenSoBanNganh"/>
				</td>			
			</tr>
			
			<tr>
				<td>
					<liferay-ui:message key="dia-chi" />
				</td>
				
				<td>
					<input type="text" name="<portlet:namespace/>diaChi" id="<portlet:namespace/>diaChi" />
				</td>			
			</tr>
			
			<tr>
				<td>
					<liferay-ui:message key="sdt" />
				</td>
				
				<td>
					<input type="text" name="<portlet:namespace/>sDT" id="<portlet:namespace/>sDT" value="" />
				</td>			
			</tr>
			
			<tr>
				<td>
					<liferay-ui:message key="fax" />
				</td>
				
				<td>
					<input type="text" name="<portlet:namespace/>fax" id="<portlet:namespace/>fax" value="" />
				</td>			
			</tr>
			
			<tr>
				<td>
					<liferay-ui:message key="email" />
				</td>
				
				<td>
					<input type="text" name="<portlet:namespace/>email" id="<portlet:namespace/>email" value="" />
				</td>			
			</tr>
			
			<tr>
				<td>
					<liferay-ui:message key="website" />
				</td>
				
				<td>
					<input type="text" name="<portlet:namespace/>website" id="<portlet:namespace/>website" value="" />
				</td>			
			</tr>
			
			<tr>
				<td>
					<liferay-ui:message key="nguoi-lien-he" />
				</td>
				
				<td>
					<input type="text" name="<portlet:namespace/>nguoiLienHe" id="<portlet:namespace/>nguoiLienHe" value="" />
				</td>			
			</tr>
			
			<tr>
				<td>
				</td>
				<td>
					<input type="submit" class="" onclick="addSoBanNganh()" value="<liferay-ui:message key="luu" />" id="<portlet:namespace/>luu" /> 
					<input type="submit" class="" onclick="thoatAddSoBanNganh()" value="<liferay-ui:message key="thoat" />"  id="<portlet:namespace/>thaoTac" />
				</td>			
			</tr>
		</table>
	</form>
</div>


<script  type="text/javascript">
function validationFromAddSoBanNganh(){
	var tenSoBanNganh = $("#<portlet:namespace/>tenSoBanNganh");
	if(!tenSoBanNganh || $.trim(tenSoBanNganh.val()) == ""){
		showPopupConfirm('<liferay-ui:message key="xin-vui-long-nhap-thong-tin" />  : [<liferay-ui:message key="ten-so-ban-nganh" />]',['Ok'],function(index){
			tenSoBanNganh.focus();				
		});
		return false;
	}
	var diaChi = $("#<portlet:namespace/>diaChi");
	if(!diaChi || $.trim(diaChi.val()) == ""){
		showPopupConfirm('<liferay-ui:message key="xin-vui-long-nhap-thong-tin" />  : [<liferay-ui:message key="dia-chi" />]',['Ok'],function(index){
			diaChi.focus();				
		});
		return false;
	}
	
	var sDT = $("#<portlet:namespace/>sDT");
	if(!sDT || $.trim(sDT.val()) == ""){
		showPopupConfirm('<liferay-ui:message key="xin-vui-long-nhap-thong-tin" />  : [<liferay-ui:message key="so-dien-thoai" />]',['Ok'],function(index){
			sDT.focus();				
		});
		return false;
	}
	
	var nguoiLienHe = $("#<portlet:namespace/>nguoiLienHe");
	if(!nguoiLienHe || $.trim(nguoiLienHe.val()) == ""){
		showPopupConfirm('<liferay-ui:message key="xin-vui-long-nhap-thong-tin" />  : [<liferay-ui:message key="nguoi-lien-he" />]',['Ok'],function(index){
			nguoiLienHe.focus();				
		});
		return false;
	}
	var email = $("#<portlet:namespace/>email");
	if(email &&  $.trim(email.val()) != ""){
		console.log('email 11 :'+ email.val());
		return validateEmail(email.val());
	}
	return true;
};

function addSoBanNganh(){
	if(validationFromAddSoBanNganh()){
		showPopupConfirm('<liferay-ui:message key="ban-co-muon-luu-thong-tin" />',['Yes','No'],function(index){
			if (index == 0){
				var url = '<%=addSoBanNganhURL.toString()%>';
				$("#<portlet:namespace/>fmThemMoiSoBanNganh").attr('action', url);
				$("#<portlet:namespace/>fmThemMoiSoBanNganh").attr('onsubmit', 'return true;');
				$("#<portlet:namespace/>fmThemMoiSoBanNganh").submit();
			}
		});	
	}
};
function thoatAddSoBanNganh(){
	location.href = '<%=backURL.toString()%>';
}
</script>


